#include "heard.h"

void *thread_main(void *p){
    status_t *pool = (status_t*)p;

    while(1){
        int net_fd = 0;
        pthread_mutex_lock(&pool->lock);
        while(pool->b_queue.size<=0){
            pthread_cond_wait(&pool->cond, &pool->lock);
        }

        dequeue(&pool->b_queue,&net_fd);

        pthread_mutex_unlock(&pool->lock);

        do_worker(net_fd);

        close(net_fd);
    }

    return NULL;
}
